package edu.calvin.djs32.cs214.interpreters.frontend;

import static org.norecess.antlr.Assert.assertTree;

import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.RecognitionException;
import org.junit.Before;
import org.junit.Test;


public class Hobbes2008FrontEndTest {
	private Hobbes2008FrontEnd myFrontEnd;
	@Before
	public void setUp() {
		myFrontEnd = new Hobbes2008FrontEnd();
	}
	
	@Test
	public void shouldProcessIntegerProgram() throws RecognitionException {
		assertTree(Hobbes2008Parser.INTEGER, "(123)", myFrontEnd.process(new ANTLRStringStream("123")));
		assertTree(Hobbes2008Parser.INTEGER, "(-123)", myFrontEnd.process(new ANTLRStringStream("-123")));
		assertTree(Hobbes2008Parser.INTEGER, "(0x123f)", myFrontEnd.process(new ANTLRStringStream("0x123f")));
	}
	
	@Test
	public void shouldProcessStringProgram() throws RecognitionException {
		assertTree(Hobbes2008Parser.STRING, "('foo')", myFrontEnd.process(new ANTLRStringStream("'foo'")));
		assertTree(Hobbes2008Parser.STRING, "('foo bar')", myFrontEnd.process(new ANTLRStringStream("'foo bar'")));
		assertTree(Hobbes2008Parser.STRING, "(' ')", myFrontEnd.process(new ANTLRStringStream("' '")));
	}

}
